namespace WP7Contrib.Services.BingMaps.Model
{
    using System;
    using Common;

    public class Landmark : BaseModel, IEquatable<Landmark>, ICloneable<Landmark>
    {
        public static Landmark Empty { get { return new Landmark(); } }

        private string areaName;
        private string postalCode;

        public Landmark()
        {
            this.areaName = string.Empty;
            this.postalCode = string.Empty;
        }

        public string AreaName
        {
            get
            {
                return this.areaName;
            }
            set
            {
                this.SetPropertyAndNotify(ref this.areaName, value, () => this.AreaName);
            }
        }

        public string PostalCode
        {
            get
            {
                return this.postalCode;
            }
            set
            {
                this.SetPropertyAndNotify(ref this.postalCode, value, () => this.PostalCode);
            }
        }

        public bool HasPostalCode
        {
            get { return !string.IsNullOrEmpty(this.postalCode); }
        }

        public static bool operator ==(Landmark l1, Landmark l2)
        {
            return Equals(l1, l2);
        }

        public static bool operator !=(Landmark l1, Landmark l2)
        {
            return !Equals(l1, l2);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
            {
                return false;
            }

            return obj is Landmark && this.Equals((Landmark)obj);
        }

        public override int GetHashCode()
        {
            return this.CombineHashCodes(this.AreaName, this.PostalCode);
        }

        public bool Equals(Landmark landmark)
        {
            if (ReferenceEquals(null, landmark))
            {
                return false;
            }

            if (this.AreaName != landmark.AreaName)
            {
                return false;
            }

            if (this.PostalCode != landmark.PostalCode)
            {
                return false;
            }

            return true;
        }

        public Landmark ShallowClone()
        {
            return DeepClone();
        }

        public Landmark DeepClone()
        {
            var landmark = new Landmark
            {
                AreaName = this.AreaName,
                PostalCode = this.PostalCode
            };

            return landmark;
        }
    }
}